package me.zhengjie.modules.business.domain;/*
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;

/**
 * 流量层
 **/
@Entity
@Data
@Table(name="flow_layer")
public class FlowLayerDO implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    private Integer id;

    @Column(name = "name")
    @ApiModelProperty(value = "流量层的名字")
    private String name;

//    @Column(name = "app_id")
//    @ApiModelProperty(value = "appId")
//    private String appId;

    @Column(name = "create_time")
    @ApiModelProperty(value = "createTime")
    private Timestamp createTime;

    @Column(name = "create_by")
    @ApiModelProperty(value = "createBy")
    private Integer createBy;

    @JoinColumn(name="app_id")
    @OneToOne
    private ApplicationSimpleDO app;

    //    @OneToMany(mappedBy = "flow_id",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    @JoinColumn(name = "layer_id")
    @OneToMany
    private List<SimpleExperimentDO> experiments;

    public void copy(FlowLayerDO source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}